﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace MoetutuTranslate.Helper
{
    class WebHelper
    {  /// <summary>
       /// 同步get请求
       /// </summary>
       /// <param name="url"></param>
       /// <returns></returns>
        public static String HttpGet(String url)
        {
            String HtmlCode = "";

            using (WebClient webClient = new WebClient())
            {

                try
                {
                    webClient.Headers.Add("User-Agent", StaticValue.UserAgent);
                    webClient.Headers.Add("Accept-Language", "zh-CN,zh;q=0.9");
                    HtmlCode = new StreamReader(webClient.OpenRead(url)).ReadToEnd();

                }
                catch (Exception ex)
                {

                    PrintLog.Log(ex.Message);
                }
            }
            return HtmlCode;

        }
    }
}
